#include <iostream>

/*

    运算符++ 和 运算符 -- 的重载
*/

class Point
{
public:
    int x;
    int y;

    Point() : x(0), y(0) {}

    Point(int x, int y) : x(x), y(y)
    {
        std::cout << "构造函数调用了" << std::endl;
    }

    void display()
    {
        std::cout << "X: " << x << "\tY: " << y << std::endl;
    }

    Point operator-(const Point &p)
    {
        return {x - p.x, y - p.y};
    }

    Point operator--()
    {
        x--;
        y--;
        return *this;
    }

    Point operator--(int)
    {
        Point temp = Point(*this);
        x--;
        y--;
        return temp;
    }
};

Point operator++(Point &point)
{
    point.x++;
    point.y++;
    return point;
}

Point operator++(Point &point, int)
{
    Point temp = Point(point);
    point.x++;
    point.y++;
    return temp;
}

int main(int argc, char const *argv[])
{
    

    Point p1(10, 20);

    // Point p2 = ++p1;

    // p2.display();
    // p1.display();

    // Point p3 = --p1;

    // p3.display();
    // p1.display();

    Point p4 = p1--;

    p4.display();
    p1.display();

    return 0;
}
